https://leetcode.cn/problems/find-first-and-last-position-of-element-in-sorted-array/
class Solution {
public:
    int searchleft(vector<int>& nums, int target)
    {
        int left=0,right=nums.size()-1;
        //[小于][大于等于]
        while(left<right)
        {
            int mid=left+(right-left)/2;
            if(nums[mid]< target)
                left=mid+1;
            else 
                right=mid;
        }
        return nums[left]==target?left:-1;
    }


    int searchright(vector<int>& nums, int target)
    {
        int left=0,right=nums.size()-1;
        //[小于等于][大于]
        while(left<right)
        {
            int mid=left+(right-left+1)/2;
            if(nums[mid]<=target)
                left=mid;
            else 
                right=mid-1;
        }
        return nums[right]==target?right:-1;

    }
    vector<int> searchRange(vector<int>& nums, int target) {
        if(nums.size()==0)
            return {-1,-1};
        int left=searchleft(nums,target);
        int right=searchright(nums,target);
        return {left,right};
    }
};